package cn.test;

import cn.test.conf.SpringConfig;
import cn.test.conf.DubboConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @auther hanchao
 * @date 2016/11/9 17:01
 */
@EnableAutoConfiguration
public class App {

    public static final String SHUTDOWN_HOOK_KEY = "dubbo.shutdown.hook";
    private static volatile boolean running = true;

    public static void main(String[] args) {
        //new SpringApplicationBuilder().sources(SpringConfig.class).web(false).run(args);
        ConfigurableApplicationContext appliation = SpringApplication.run(new Object[]{SpringConfig.class, DubboConfig.class}, args);

        try {
            System.in.read();
        } catch(Exception e){
            e.printStackTrace();
        }

        //shutdown
        /*if ("true".equals(System.getProperty(SHUTDOWN_HOOK_KEY))) {
            Runtime.getRuntime().addShutdownHook(new Thread() {
                public void run() {
                    synchronized (App.class) {
                        running = false;
                        App.class.notify();
                    }
                }
            });
        }

        synchronized (App.class) {
            while (running) {
                try {
                    App.class.wait();
                } catch (Throwable e) {
                }
            }
        }

        System.exit(0);*/
    }
}
